package com.project.lk.nurseapp.utils;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.bigkoo.pickerview.OptionsPickerView;
import com.project.lk.nurseapp.R;

import java.util.List;

/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class PickerViewManager {

    private static String categoryId;
    public static OptionsPickerView createCategoryPicker(final List list , final List list2,Context context, final TextView itemTextView){

        OptionsPickerView mOptionsPickerView = new OptionsPickerView.Builder(context, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                itemTextView.setText(String.valueOf(list.get(options1)));
                categoryId = String.valueOf(list2.get(options1));
            }


        }).setCancelColor(context.getResources().getColor(R.color.heard_background))
           .setSubmitColor(context.getResources().getColor(R.color.heard_background)) .build();


        // 设置数据
        mOptionsPickerView.setPicker(list);
        return mOptionsPickerView;
    }


    public static String getCategoryId() {
        return categoryId;
    }
    public static OptionsPickerView createOnePicker(final List list ,Context context, final TextView itemTextView){

        OptionsPickerView mOptionsPickerView = new OptionsPickerView.Builder(context, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                itemTextView.setText(String.valueOf(list.get(options1)));
            }


        }).setCancelColor(context.getResources().getColor(R.color.heard_background))
                .setSubmitColor(context.getResources().getColor(R.color.heard_background)) .build();


        // 设置数据
        mOptionsPickerView.setPicker(list);
        return mOptionsPickerView;
    }

    public static OptionsPickerView createThreePicker(final List<String> oneList, final List<List<String>> twoList , final List<List<List<String>>> threeList, Context context, final TextView itemTextView){

        OptionsPickerView mOptionsPickerView = new OptionsPickerView.Builder(context, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                String text = oneList.get(options1)+"-"+
                        twoList.get(options1).get(options2)+"-"+
                        threeList.get(options1).get(options2).get(options3);
                itemTextView.setText(text);
            }
        }).setCancelColor(context.getResources().getColor(R.color.heard_background))
                .setSubmitColor(context.getResources().getColor(R.color.heard_background)) .build();

        // 设置数据
        mOptionsPickerView.setPicker(oneList,twoList,threeList);


        return mOptionsPickerView;
    }
}
